﻿Imports System.Data.OleDb
Public Class TheTinDungDAO
    Shared conn_str As String = My.Settings.ConnectionString
    Shared Function GetAll(ByVal MaUser As Integer) As DataTable
        Dim dt As New DataTable
        Dim query As String = "select * from TheTinDung join nganhang on nganhang.manganhang = TheTinDung.manganhang where MaUser = ?"
        Try
            Dim adapter As New OleDbDataAdapter(query, conn_str)
            adapter.SelectCommand.Parameters.AddWithValue("@MaUser", MaUser)
            adapter.Fill(dt)
        Catch Loi As CustomException.MyException
            Loi.Show(query, conn_str)
        End Try
        Return dt
    End Function
    Shared Function MaNganHang(ByVal MaTheTinDung As String) As Integer
        Dim ret As Integer
        Dim query As String = "select MaNganHang from TheTinDung where MaTheTinDung = ?"
        Try
            Dim conn As New OleDbConnection(conn_str)
            Dim cmd As New OleDbCommand(query, conn)
            conn.Open()
            cmd.Parameters.AddWithValue("@MaTheTinDung", MaTheTinDung)
            ret = cmd.ExecuteScalar()
            conn.Close()
        Catch Loi As CustomException.MyException
            Loi.Show(query, conn_str)
        End Try
        Return ret
    End Function

End Class
